-
Notifications
You must be signed in to change notification settings - Fork 6
add a connection handler pool #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
So far no tests or anything, just to put it somewhere.
CC @b5, we talked about this. Something like this is useful for normal connections, but essential to deal with the situation where you want 0rtt connections for occasional short lived interactions and then flip to keeping the connection around if the interactions become more frequent. |
The original approach turns the connection pool into a combination of connection pool and task runner, and also is very unergonomic. So I ended up doing the following: There is a ConnectionRef which impls Deref but has an additional field that tracks lifetime of the ConnectionRef. You must keep the ConnectionRef alive while you are using the connection in any way, but there is no way around this short of completely changing quinn. When no more ConnectionRefs are used, the connection goes into idle state. After an idle timeout, it gets closed. If there is a demand for more connections before idle connections are closed, one of the idle connections (the oldest) is reclaimed. If there are no idle connections, and you are at capacity, you get an error. There is currently no way to get notified when connection slots are available. We could change this by making some statistics (e.g. total number of connections and number of idle connections) available via a n0_watcher::Watchable. |
we don't expect connect to panic, so we don't need to isolate it.
This is a compromise that tries to provide a connection pool even though iroh/quinn design does not make this easy. Connections are Clone, but they want to be owned by the pool. So you get a chance to work with a connection but are not supposed to clone them out.
Questions:
Does the thing in the main actor have to be a JoinSet, or could it also just be a FuturesUnordered?
Do we need a way to watch currently active and idle connections?